package ru.averta.notes.dao.impl;

import java.io.Serializable;
import java.util.Collection;

import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import ru.averta.notes.dao.UserableDao;
import ru.averta.notes.domain.User;
import ru.averta.notes.domain.flags.IUserable;

@Repository
public abstract class UserableDaoImpl<T extends IUserable, PK extends Serializable> extends GenericDaoHibernateImpl<T, PK> implements
        UserableDao<T, PK> {

    @SuppressWarnings("unchecked")
    public Collection<T> findByUser(User user) {
        return createCriteria().add(Restrictions.eq("user", user)).list();
    }
    
}
